#include "stdafx.h"
/// Copyright 2012, Alex Averian, Yonan Research
/// Released under BSD Licence


#pragma warning(disable : 4996)	// disable bogus deprecation warning


#include "qnetwork.h"
using namespace micro::net;



 

//#include <windows.h>
//#include <winsock.h>
#include <Winsock2.h>
 
#include <ws2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")



using namespace micro::net;
QNetInitializer::QNetInitializer(void)
{
	NetStartup(2,2);
}


QNetInitializer::~QNetInitializer(void)
{
	WSACleanup();
}



bool QNetInitializer::NetStartup( int hi, int lo )
{

	WSADATA wsadata = { 0 };
	WORD winsock_ver = MAKEWORD( hi, lo );

	if ( WSAStartup( winsock_ver, &wsadata ) )
	{
		return false;
	}

	if ( LOBYTE( wsadata.wVersion ) != LOBYTE( winsock_ver ) )
	{
		return false;
	}

	return true;
}

